﻿<?php
require_once ('start_session.php');
require_once('db.php');

	$playingCards = $_POST['cardId'];
	$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
	$gameQuery = "INSERT INTO game (start, player_1, player_2) VALUES (NOW(), 5, 6)";
	$gameResult = mysqli_query($dbc, $gameQuery)or die(mysqli_error($dbc));
	$game_id = mysqli_insert_id($dbc);
	
	foreach($playingCards as $card){
			$query = "INSERT INTO card (game_id,image_id) VALUES ($game_id,$card)";		
		$result = mysqli_query($dbc, $query) or die(mysqli_error($dbc));
		
	}

?>